home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.2 Development Libraries / SGI IRIX 6.2 Development Libraries.iso / dist / complib.idb / usr / share / src / Complib / examples / FFT1DU_ex.f.z / FFT1DU_ex.f
Encoding:
Text File  |  1996-03-15  |  3.7 KB  |  122 lines

  1. c
  2. c FFT1DU_ex.f
  3. c
  4. c      This simple example illustrates the use of the FORTRAN
  5. c    interface to the complib FFT routines to calculate a 
  6. c       real-to-complex and complex-to-complex FFT.
  7. c
  8. c    This program reads the number of samples N for the sequence,
  9. c    generates a real and complex sample input arrays, and calculates 
  10. c    the transform.
  11. c
  12. c
  13. c Copyright 1995, Silicon Graphics, Inc.
  14. c ALL RIGHTS RESERVED
  15. c
  16. c UNPUBLISHED -- Rights reserved under the copyright laws of the United
  17. c States.   Use of a copyright notice is precautionary only and does not
  18. c imply publication or disclosure.
  19. c
  20. c U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  21. c Use, duplication or disclosure by the Government is subject to restrictions
  22. c as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  23. c in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  24. c in similar or successor clauses in the FAR, or the DOD or NASA FAR
  25. c Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  26. c 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  27. c
  28. c THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  29. c INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  30. c DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  31. c PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  32. c GRAPHICS, INC.
  33. c
  34. c
  35. c     To build executable:
  36. c           % f77 -o FFT1DU_ex FFT1DU_ex.f -lcomplib.sgimath
  37. c
  38. c     To run:
  39. c           % FFT1DU_ex
  40. c
  41. c     Input:
  42. c           4
  43. c
  44. c     Output:
  45. c           Input Real Array of size 4 :
  46. c               0.00  1.00  2.00  3.00
  47. c          Input Complex Array of size 8 :
  48. c            0.00  0.00  1.00  0.00  2.00  0.00  3.00  0.00
  49. c          FFT of Real Array of size 6 :
  50. c              6.00  0.00 -2.00  2.00 -2.00  0.00
  51. c          FFT of Complex Array of size 8
  52. c            6.00  0.00 -2.00  2.00 -2.00  0.00 -2.00 -2.00
  53. c
  54. c
  55. c          % FFT1DU_ex
  56. c
  57. c    Input:
  58. c          5
  59. c
  60. c     Output:
  61. c          Input Real Array of size 5 :
  62. c            0.00  1.00  2.00  3.00  4.00
  63. c          Input Complex Array of size10 :
  64. c            0.00  0.00  1.00  0.00  2.00  0.00  3.00  0.00  4.00  0.00
  65. c          FFT of Real Array of size 6 :
  66. c            10.00  0.00 -2.50  3.44 -2.50  0.81
  67. c          FFT of Complex Array of size10 :
  68. c            10.00  0.00 -2.50  3.44 -2.50  0.81 -2.50 -0.81 -2.50 -3.44
  69.       PROGRAM FFT1DU_ex
  70.       IMPLICIT NONE
  71.       INTEGER     I, N, SIZE
  72.       PARAMETER  ( SIZE = 8 )
  73.       REAL        FARRAY( 2*((SIZE+2)/2) ), FCOEF( SIZE+15 )
  74.       COMPLEX     CARRAY( SIZE ),           CCOEF( SIZE+15 )
  75.  
  76. c
  77. c     Read the number of samples N.
  78. c
  79.       READ( 5, * ) N
  80. c
  81. c     Generate the real and complex sequences.
  82. c
  83.       DO I = 1, N
  84.          FARRAY( I ) =   REAL( I ) - 1.
  85.      CARRAY( I ) = ( REAL( I ) - 1., 0.)
  86.       END DO 
  87.  
  88. c
  89. c     Print out input data
  90. c
  91.       WRITE( 6,'( A, I2, A )' ) 
  92.      &       "Input Real Array of size", N, " :"
  93.       WRITE( 6,'( 10F6.2 )' ) ( FARRAY( I ), i = 1, n )
  94.       WRITE( 6,'( A, I2, A )' )
  95.      &       "Input Complex Array of size", 2*N, " :"
  96.       WRITE( 6,'( 10F6.2 )' )
  97.      &       ( REAL( CARRAY( I ) ), IMAG( CARRAY( I ) ),I = 1, N )
  98.    
  99. c
  100. c     Calculate the transforms.
  101. c
  102.       CALL SCFFT1DUI ( N, FCOEF )
  103.       CALL SCFFT1DU  ( -1, N, FARRAY, 1, FCOEF )         
  104.       CALL CFFT1DI   ( N, CCOEF )
  105.       CALL CFFT1D    ( -1, N, CARRAY, 1, CCOEF )
  106.  
  107. c
  108. c     Print out transforms.
  109. c
  110.       WRITE( 6, '( A, I2, A )' ) 
  111.      &       "FFT of Real Array of size", 2*( ( N+2 )/2 ), " :"
  112.       WRITE( 6, '( 10F6.2 )' ) 
  113.      &       ( FARRAY( I ), I = 1, 2*( ( N+2 )/2 ) )
  114.       WRITE( 6, '( A, I2, A )' )
  115.      &       "FFT of Complex Array of size", 2*N, " :"
  116.       WRITE( 6, '( 10F6.2 )' )
  117.      &       ( REAL( CARRAY( I ) ), IMAG( CARRAY( I ) ), I = 1, N )
  118.  
  119.       STOP
  120.       END
  121.